local Locales = {
	["Blade-Wind the Invoker"] = {
		[1] = "Blade-Wind the Invoker",
		[2] = "Klingenwind der Beschwörer",
		[3] = "Lamevent l'Invocateur",
	},
	["Thunder Cross"] = { --63231
		[1] = "Thunder Cross",
		[2] = "Donnerkreuz",
		[3] = "Croix de tonnerre",
	},
	["Sonic Barrier"] = { --45481
		[1] = "Sonic Barrier",
		[2] = "Schallmauer",
		[3] = "Barrière sonique",
	},
	["Electrostatic Pulse"] = { --39074
		[1] = "Electrostatic Pulse",
		[2] = "Elektrostatischer Impuls",
		[3] = "Pulsation électrostatique",
	},
	["Boss immune, kill adds!"] = {
		[1] = "Boss immune, kill adds!",
		[2] = "Boss immun, Adds töten!",
		[3] = "Boss immune, kill adds!",
	},
	["The Invoker has lost his protection!"] = {
		[1] = "The Invoker has lost his protection!",
		[2] = "Der Vorsänger hat keinen Schutz mehr!",
		[3] = "The Invoker has lost his protection!",
	},
}

local function STLInvoker(tUnits)
	local currTime = GameLib.GetGameTime()
	for unitid, unitdata in pairs(tUnits) do
		local unitname = unitdata.unit:GetName()
		if unitname == Raiderino.L["Blade-Wind the Invoker"] then
			local castname = Raiderino:GetCast(unitid,unitdata.unit)
			if castname then
				if castname == Raiderino.L["Thunder Cross"] then
					if Raiderino:FeatureCheck("Blade-Wind the Invoker","Thunder Cross") then
						local msg = {text = "Thunder Cross", maxtime = 11.5, icon = nil, destroyAtEnd = false}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Sonic Barrier"] then
					if Raiderino:FeatureCheck("Blade-Wind the Invoker","Sonic Barrier") then
						local msg = {text = "Boss immune, kill adds!", maxtime = 30, icon = nil, destroyAtEnd = false}
						Raiderino.notifications:AddTimer(msg)
						Raiderino:PhaseSwitch("Blade-Wind the Invoker",2)
					end
				elseif castname == Raiderino.L["Electrostatic Pulse"] then
					if Raiderino:FeatureCheck("Blade-Wind the Invoker","Electrostatic Pulse") then
						local msg = {text = "Electrostatic Pulse", maxtime = 5.5, icon = nil, destroyAtEnd = false}
						Raiderino.timers:AddTimer(msg)
					end
				else
					Raiderino:UntimedCastAdd(unitname,castname)
				end
			end
		end
	end
end

local function PhaseInvoker(phase)
	if phase == 2 then
		if Raiderino:FeatureCheck("Blade-Wind the Invoker","Thunder Cross") then
			local msg = {text = "Thunder Cross", maxtime = 11.5, icon = nil, destroyAtEnd = false}
			Raiderino.timers:AddTimer(msg)
		end
	elseif phase == 3 then
		if Raiderino.notifications.content["Boss immune, kill adds!"] then
			Raiderino.notifications.content["Boss immune, kill adds!"].Frame:Destroy()
			Raiderino.notifications.content["Boss immune, kill adds!"] = nil
		end
		if Raiderino.timers.content["Thunder Cross"] then
			Raiderino.timers.content["Thunder Cross"].Frame:Destroy()
			Raiderino.timers.content["Thunder Cross"] = nil
		end
	end
end

local function StartInvoker()
	if Raiderino:FeatureCheck("Blade-Wind the Invoker","Thunder Cross") then
		local msg = {text = "Thunder Cross", maxtime = 5, icon = nil, destroyAtEnd = false}
		Raiderino.timers:AddTimer(msg)
	end
	Raiderino:AddDatachronHandler(
		"The Invoker has lost his protection!",
		function()
			Raiderino:PhaseSwitch("Blade-Wind the Invoker",3)
		end
	)
end

local encounteroptions = {
	enabled = true,
	position = 1,
	zone = "Stormtalon's Lair",
	fBossFunction = STLInvoker,
	fPhaseFunction = PhaseInvoker,
	fOnStartCombat = StartInvoker,
	features = {
		["Thunder Cross"] = {
			displayname = "Thunder Cross",
			enabled = true
		},
		["Sonic Barrier"] = {
			displayname = "Sonic Barrier",
			enabled = true
		},
		["Electrostatic Pulse"] = {
			displayname = "Electrostatic Pulse",
			enabled = true
		},
	},
}

if _G["RaiderinoLibs"] == nil then
	_G["RaiderinoLibs"] = { }
end
if _G["RaiderinoLibs"]["Encounters"] == nil then
	_G["RaiderinoLibs"]["Encounters"] = { }
end
_G["RaiderinoLibs"]["Encounters"]["Blade-Wind the Invoker"] = encounteroptions

if _G["RaiderinoLibs"]["Locales"] == nil then
	_G["RaiderinoLibs"]["Locales"] = { }
end
for locale, localedata in pairs(Locales) do
	if not RaiderinoLibs.Locales[locale] then
		RaiderinoLibs.Locales[locale] = {}
		for i,localestring in pairs(localedata) do
			RaiderinoLibs.Locales[locale][i] = localestring
		end
	end
end